package cn.enilu.flash.dao.park;


import cn.enilu.flash.bean.entity.park.ParkingInfo;
import cn.enilu.flash.dao.BaseRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;


public interface ParkingInfoRepository extends BaseRepository<ParkingInfo,Long>{

    @Query(nativeQuery = true, value = "select a.id, CONCAT(a.`code`,' / ',a.`name`) as title\n" +
            "from parking_info a left join (select * from parking_contract where end_date>now())b on a.id=b.parking_id \n" +
            "where b.id is null\n" +
            "and a.owner_flag=0\n" +
            "and a.community_id=?1\n" +
            "order by a.`code` ASC")
    List<Map<String, Object>> getParkings(Long communityId);
}

